##
#   Project: BlueDUN
#            Internet connection manager for bluetooth devices.
#    Author: Fabio Castelli <muflone@vbsimple.net>
# Copyright: 2009 Fabio Castelli
#   License: GPL-2+
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the Free
#  Software Foundation; either version 2 of the License, or (at your option)
#  any later version.
# 
#  This program is distributed in the hope that it will be useful, but WITHOUT
#  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
#  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
#  more details.
# 
# On Debian GNU/Linux systems, the full text of the GNU General Public License
# can be found in the file /usr/share/common-licenses/GPL-2.
##

import gtk
import gtk.glade
import handlepaths
import gettext
from gettext import gettext as _

# Load domain for translation
for module in (gettext, gtk.glade):
  module.bindtextdomain(handlepaths.APP_NAME, handlepaths.getPath('locale'))
  module.textdomain(handlepaths.APP_NAME)

def readTextFile(filename):
  "Read a text file and return its content"
  try:
    f = open(filename, 'r')
    text = f.read()
    f.close()
  except:
    text = ''
  return text

def showWindow():
  "Show the about dialog"
  about = gtk.AboutDialog()
  about.set_program_name(handlepaths.APP_TITLE)
  about.set_version(handlepaths.APP_VERSION)
  about.set_comments(_('Internet connection manager for bluetooth devices.'))
  about.set_icon_from_file(handlepaths.get_app_logo())
  about.set_logo(gtk.gdk.pixbuf_new_from_file(handlepaths.get_app_logo()))
  about.set_copyright('Copyright 2009 Fabio Castelli')
  about.set_translator_credits(readTextFile(handlepaths.getPath('doc','translators')))
  about.set_artists(['Application icons by: Emanuele Poggi <ema.ge@yahoo.it>'])
  about.set_license(readTextFile(handlepaths.getPath('doc','copyright')))
  about.set_website_label('BlueDUN')
  gtk.about_dialog_set_url_hook(lambda url, data=None: url)
  about.set_website('http://code.google.com/p/bluedun/')
  about.set_authors(['Fabio Castelli <muflone@vbsimple.net>', 
    'http://www.ubuntutrucchi.it'])
  about.run()
  about.destroy()
